﻿using System;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace SoundReg
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /** 
         * \brief 语音更改
         */
        private void SetBtn_Click(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            RegManager manager = new RegManager();
            manager.SetRegData();
            foreach (var v in manager.regList)
            {
                ShowList(v.RegUrl, v.isRegSuccess);
            }
        }

        /** 
           * \brief 列表显示与更新
           */
        public void ShowList(string regUrl, bool isRegSuccess) 
        {
            int index = listView1.Items.Count;
            try
            {
                //读取去重后的日志内容
                listView1.Items.Add(Convert.ToString(index));
                listView1.Items[listView1.Items.Count - 1].SubItems.Add(regUrl);
                if (isRegSuccess)
                {
                    listView1.Items[listView1.Items.Count - 1].SubItems.Add("修改成功");
                }
                else
                {
                    listView1.Items[listView1.Items.Count - 1].SubItems.Add("修改失败");
                }
            }
            catch (Exception ex)
            {
                listView1.Items.Add(Convert.ToString(index));
                listView1.Items[listView1.Items.Count - 1].SubItems.Add(regUrl);
                listView1.Items[listView1.Items.Count - 1].SubItems.Add(ex.Message);
            }
        }
    }
}